<%@ page contentType="text/html;charset=UTF-8"%>
<%@page import="com.ejoysoft.util.ParamUtil"%>
<%@page import="java.util.Vector"%>
<%@page import="com.ejoysoft.conf.SysModule"%>
<%@page import="com.ejoysoft.conf.Module"%>
<%@page import="com.ejoysoft.common.exception.ApplicationException"%>
<%@page import="com.ejoysoft.wlanyz.business.Paper,com.ejoysoft.wlanyz.business.Ac"%>
<%@page import="java.util.ArrayList"%> 
<%@include file="include/jsp/head.jsp"%>

<% 
try{
String actionFlag = ParamUtil.getString(request,"actionFlag","系统首页");
String rootFlag = ParamUtil.getString(request,"rootFlag","日常管理");
String tempName = "";
 %>
 <%  
Vector vctRoot = SysModule.getModules();
Module modRoot = null;
if(vctRoot !=null)
{
  //判断顶级模块是否存在
	for (int i = 0; i < vctRoot.size(); i++) { 
		if (((Module)vctRoot.get(i)).getName().equals(rootFlag)) {
			modRoot = (Module)vctRoot.get(i);
			break;
		}
	} 
	if (modRoot == null) {
		throw new ApplicationException("系统配置错误：不存在" + rootFlag + "顶级模块！");
	}
}
%>
<html>
<head>
<title><%=application.getAttribute("APP_TITLE") %></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<link href="css/left.css" rel="stylesheet" type="text/css">

<script src="../scripts/jsframework.js"></script>
<style type="text/css">
<!--
body {
	background-color: #f2f8ff;font-size:12px;
}
.lft{ color:#FFFFFF; font-size:12px; line-height:25px; text-align:left}
.lf2{ color:#619DDB; font-size:12px;} 
-->
</style> 
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >
<form name=frm id=frm action="left.jsp" method="post" target="leftFrame">
<div class="left">
<div class="lf_tit">功能菜单</div>
<div class="lf_list">
	<ul> 
	  <%if(rootFlag.equals("日常管理")){
	 	    //判断二级模块是否存在和权限
	 	    boolean chileModuleExist = false,chileModuleRight=false;
	  		Vector vctModule = modRoot.getChildren();
	  		Module childMod = null; 
	  		if(vctModule != null)
	  		{
	  			for (int i = 0; i < vctModule.size(); i++) {
					Module mod2 = (Module)vctModule.get(i);
					if (mod2.getName().equals(actionFlag)) {
						childMod = mod2;
						chileModuleExist = true;
						if(globa.userSession.hasRight(mod2.getCode()))
							chileModuleRight = true;
						break;
					}
	  			}
	  		}
			if (!chileModuleExist) {
				throw new ApplicationException("系统配置错误：不存在" + rootFlag + "顶级模块！");
			}
			else if(!chileModuleRight)
			{
				out.println("<script>alert('对不起！您无该模块的操作权限！')</script>");
			}
		    else{
		    	Vector vctModule2 = childMod.getChildren();
		    	if(vctModule2 != null )
		    	{
		    	%><%
			    	for(int i=0;i<vctModule2.size();i++){
				    	Module childMod2 = (Module)vctModule2.get(i);
				    	if(globa.userSession.hasRight(childMod2.getCode()))
				    	{
				    		tempName = childMod2.getName();
				    		String random = String.valueOf(Math.random());
		   %>
		   			 <li><a href="<%=childMod2.getUrl()+"?random="+random %>" target="mainFrame" ><%=childMod2.getName() %></a></li>
			<%
		 				}
				    }
		 		}
			 }
		 }
		%>
	</ul>
	<div class="bot">   <%
			          		if(tempName.equals("拓扑呈现"))
			          		{
			          		    Paper obj00 = new Paper(globa,false);
				          		Ac obj = new Ac(globa);
			          			String strClassName = ParamUtil.getString(request,"strClassName","");
			          			ArrayList<String> listCities = obj.listAllCitys(""); 
			           %>
			          
			                 <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
			              
			           		 <tr>
			                   <td height="30" > 
			                   <table><tr><td>
			                      <input type="hidden" name="actionFlag" value="<%=actionFlag%>"/>
			                   <input type="hidden" name="rootFlag" value="<%=rootFlag%>"/> 
			                   <input type="text" style="width: 100px ; height:22px;" class="sel1" name="strClassName" value="<%=strClassName %>" />&nbsp;&nbsp;
			                   </td>
			                   <td>
			                       <img onClick="document.getElementById('frm').submit()" src="images/lfcx.jpg" width="46" height="24" />
			                   </td></tr></table>
			                   </td>
			                </tr>
			                <tr><td>
			                <table  width="90%">
		 				<%
		 						if(strClassName!=null && !strClassName.equals(""))
		 						{
				          			Vector<Ac> vctClassTwoAcs = obj.listClassTwoAcs(" where classTwoAC like '%"+strClassName+"%'");
				          			for(int k=0;k<vctClassTwoAcs.size();k++){
				          				Ac obj0 = vctClassTwoAcs.get(k);
				          				String classTwoAc = obj0.getClassTwoAC();
				          				String classTwoAcId = obj0.getStrId();
				          			%>
				          				<tr><td><a href="topology/topology_show.jsp?classTwoACName=<%=classTwoAcId%>"  target="mainFrame">*<%=classTwoAc%></a> </td></tr> 
				          		<%
				          			}
		 						}
		 						%>
			                </table>
			                </td></tr></table>
		 						<%
		 						if(listCities !=null )
			 					{
			 					%>  
			 					 <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
			 					 <tr><td height="30"></td></tr>
			 					 <tr>
			 					 <td class="seltitle">
			 					 	热点选择
			 					 	<br/>&nbsp;
			 					 </td></tr>
			 					 </table>
			 					 <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
									<tr> <td style ='overflow: scroll;'>
										<script language="javascript"> 
										  var data={};
										   data["-1_1"] = "text:江苏省;url:javascript:void(0);target:leftFrame;";
								<%  
			 						for(int k=0;k<listCities.size();k++)
			 						{
										String cityName = listCities.get(k);
										ArrayList<String> listCountries = obj.listCountriesOfCity(" where strCity='"+cityName+"' order by strCountry");
										%>
										 	 data['<%="1_"+cityName+"cityName"%>'] = "text:"+'<%=cityName%>'+";target:leftFrame;";
										<%
										if(listCountries != null )
										{
											for(int m=0;m<listCountries.size();m++)
											{
												String countryName = listCountries.get(m);
												ArrayList<String> listClassOneAcs = obj.listClassOneAcs(" where strCity='"+cityName+"' and strCountry='"+countryName+"' order by classOneAC");
										%>
										 			<%
												for(int m1 = 0 ;m1<listClassOneAcs.size();m1++)
												{
													String oneAcName = listClassOneAcs.get(m1);
													Vector<Ac> listClassTwoAcs = obj.listClassTwoAcs(" where strCity='"+cityName+"' and strCountry='"+countryName+"' and classOneAC='"+oneAcName+"' order by classTwoAC");
										%>
											 		 
										<%			
													if(listClassTwoAcs !=null)
													{
														for(int m2=0;m2<listClassTwoAcs.size();m2++)
														{
															Ac ac = listClassTwoAcs.get(m2);
															String twoAcName = ac==null?"":ac.getClassTwoAC();
															String twoAcId = ac==null?"":ac.getStrId();
															int papernumber = obj00.getPaperNum(" where acname = '"+twoAcId+"'"); 
															if(papernumber!=0)
															{  
															String oneAcName1 =  oneAcName;
															/*if (oneAcName1.length()>6){
															oneAcName1 = oneAcName1.substring(0,6)+"...";
															}*/
															String twoAcName1 =  twoAcName;
															/*if (twoAcName1.length()>6){
															twoAcName1 = twoAcName1.substring(0,6)+"...";
															}*/
														%> 
														      data['<%=cityName+"cityName_"+countryName+"countyName"%>'] = "text:"+'<%=countryName%>'+";target:leftFrame;";
									                          data['<%=countryName+"countyName_"+oneAcName+"classOneACName"%>'] = "text:"+'<%=oneAcName1%>'+";target:leftFrame;";
											 				 data['<%=oneAcName+"classOneACName_"+twoAcName+"classTwoACName"%>'] = "text:"+'<%=twoAcName1%>'+";url:topology/topology_show.jsp?classTwoACName=<%=twoAcId%>;target:mainFrame;";
														<%
														}
														}
													}
												}
											}
										}		 						
			 						}
			 			%>
			 					   Using("System.Web.UI.WebControls.MzTreeView");
								   var a = new MzTreeView("left"); 
								   a.dataSource = data
								   //a.rootId="1";
								   a.autoSort=true;
								   a.useCheckbox=true;
								   a.canOperate=true; 								  
								   document.write(a.render());
								   a.expandLevel(3);
		
								  </script>
								</td>
							 </tr>
			 			<%
		 						}
		 				%>
		 				</table> 
		 				<% 
		 					}  %></div><%if(!actionFlag.equals("拓扑呈现")) { %>
	</div>
	<div class="lf_bt"><img src="images/lf_bt.jpg"></div>
</div>
<%
}else{
%>
	<div class="lf_bt"></div>

<% 
}

%>
			  </form>     
</body>
</html>
<%}
catch(Exception e){e.printStackTrace();} %>
<%@ include file="include/jsp/footer.jsp"%>